#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
    string s;
    string t="";
    getline(cin,s);
    map<string,int> wordfrequence;
    for(int i=0;i<s.length();i++){
	if(isalnum(s[i]))
	{
	    s[i]=tolower(s[i]);
	    t=t+s[i];
	}
	if(i==s.length()-1||!isalnum(s[i])){
	    if(t.length()){
		wordfrequence[t]++;
	    }
	    t="";
	}
    }
    int max=0;
    string finals;
    for(auto it=wordfrequence.begin();it!=wordfrequence.end();it++){
	if(it->second>max){
	    max=it->second;
	    finals=it->first;
	}
    }
    cout<<finals<<" "<<max<<endl;
}
